/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package boundless.test;
//Comment
import boundless.ejb.*;
import boundless.entities.*;
import boundless.managedbeans.*;
import java.util.*;
//small change
/**
 *
 * @author hendrikdekock
 */
public class DraftTester {
    
    public static void start(RequestBean rb) {
        System.out.println("THE TEST HAS BEGUN!!");
        DraftBean db = new DraftBean();
        db.setLeague(rb.getLeague(33));
        db.setReqBean(rb);
        //List<Player> testnonMeta = rb.getPlayerByNameSpec();
        System.out.println("THE TEST HAS EXITED");
        List<Player> testSearch = db.searchPlayer("Matt Ryan");
        System.out.println("SECOND TEST EXITED");
        System.out.println(testSearch.get(0));
          
        
        Player p = new Player(1, "Fred", (short) 0);
        System.out.println("ASSIGNMENT TEST");
        boolean a = rb.isPlayerAssignedToLeague(p, rb.getLeague(33));
        System.out.println("ASSIGNMENT TEST EXITED");
        //List<Player> testGet = rb.getAllPlayersOfPosition(rb.getPosition(0));
        System.out.println("CHECKING POSITION TEST EXITED");
        /*for (int i = 0; i < testGet.size(); i++) {
            System.out.println("QUARTERBACK: " + testGet.get(i));
        }*/
        
        System.out.println("FETCHING PLAYER");
        Player p1 = rb.getPlayerById(11);
        System.out.println("Player is " + p1);
        
        System.out.println("FETCHING TEAMS");
        Fantasyteams fhendrik = rb.getTeam(42);
        Fantasyteams fsam = rb.getTeam(67);
        
        System.out.println("ASSIGNING PLAYER");
        db.assignPlayer(p1, fhendrik, (short) 1);
        
        rb.synchronize();
        
        List<Playerteam> hendrikPlayers = rb.getAllAssignmentsFromLeague(rb.getLeague(33));
        for (int i = 0; i < hendrikPlayers.size(); i++) {
            System.out.println(hendrikPlayers.get(i));
        }
        
        ArrayList<Player> samsTeam = new ArrayList<Player>();
        
        samsTeam.add(rb.getPlayerById(11));
        samsTeam.add(rb.getPlayerById(13));
        samsTeam.add(rb.getPlayerById(44));
        samsTeam.add(rb.getPlayerById(34));
        samsTeam.add(rb.getPlayerById(23));
        samsTeam.add(rb.getPlayerById(56));
        //samsTeam.add(rb.getPlayerById(23));
        samsTeam.add(rb.getPlayerById(32));
        samsTeam.add(rb.getPlayerById(9));
        samsTeam.add(rb.getPlayerById(0));
        
        System.out.println("VALIDATING TEAM");
        System.out.println(db.validateTeam(samsTeam));
        
        samsTeam.remove(rb.getPlayerById(11));
        
        System.out.println("VALIDATING AGAIN");
        System.out.println(db.validateTeam(samsTeam));
        
        ArrayList<Player> samsBenchTeam = new ArrayList<Player>();
        
        samsBenchTeam.add(rb.getPlayerById(22));
        samsBenchTeam.add(rb.getPlayerById(42));
        
        db.assignTeam(samsTeam, samsBenchTeam, fsam);
    
        rb.synchronize();
    }
    
}
